package com.wpre.blogsystem.common.pojo;

import com.wpre.blogsystem.common.enums.ResultStatusEnum;
import lombok.Data;

/**
 * Created with IntelliJ IDEA.
 * Description: 统一返回结果
 * User: LianBao
 * Date: 2024-12-04
 * Time: 13:56
 */
@Data
public class Result<T> {
    private int code;
    private String massage;
    private T data;

    public static <T> Result<T> ok(T data) {
        Result<T> result = new Result<>();

        result.setCode(ResultStatusEnum.SUCCESS.getCode());
//        result.setMassage("");
        result.setMassage("");
        result.setData(data);
        return result;
    }

    public static <T> Result<T> fail(String massage) {
        Result<T> result = new Result<>();
        result.setCode(ResultStatusEnum.FAIL.getCode());
        result.setMassage(massage);
        return result;
    }

    public static <T> Result<T> fail(String massage, T data) {
        Result<T> result = new Result<T>();
        result.setCode(ResultStatusEnum.FAIL.getCode());
        result.setMassage(massage);
        return result;
    }

}
